package com.itany.springcoud.sentinel.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.itany.springcloud.common.vo.ResponseResult;
import com.itany.springcoud.sentinel.blockhandler.GlobalBlockHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @RequestMapping("/f1")
    @SentinelResource(value = "f1",blockHandler = "f1BlockHandler")
    public ResponseResult f1(){
        return ResponseResult.success();
    }

    public ResponseResult f1BlockHandler(BlockException e){
        return ResponseResult.fail("f1BlockHandler处理异常，异常为："+e);
    }

    @RequestMapping("/f2")
    @SentinelResource(value = "f2" ,blockHandlerClass = GlobalBlockHandler.class ,blockHandler = "blockHandler")
    public ResponseResult f2(){
        return ResponseResult.success();
    }


}
